package com.gp.learn.common.core.mybaitsplus;


import com.gp.learn.common.core.utils.ReflectionUtils;

/**
 * 多张表连接查询
 */
public class JoinBean {

    /**
     * 主表class
     */
    private Class mainClass;

    /**
     * 主表名
     */
    private String mainTableName;

    /**
     * 主表别名
     */
    private String mainTableAlias;

    /**
     * 主表连接字段
     */
    private String mainField;

    /**
     * 连接表class
     */
    private Class joinClass;

    /**
     * 连接表名
     */
    private String joinTableName;

    /**
     * 连接表别名
     */
    private String joinTableAlias;

    /**
     * 连接表连接字段
     */
    private String joinField;

    /**
     * 连接类型
     */
    private JoinType joinType = JoinType.LEFT;


    public JoinBean(Class mainClass, Class joinClass) {
        String mainTableName = ReflectionUtils.getTableName(mainClass);
        this.mainTableName = mainTableName;
        String mainTableAlias = ReflectionUtils.getTableAlias(mainClass);
        this.mainTableAlias = mainTableAlias;
        String joinTableName = ReflectionUtils.getTableName(joinClass);
        this.joinTableName = joinTableName;
        String joinTableAlias = ReflectionUtils.getTableAlias(joinClass);
        this.joinTableAlias = joinTableAlias;
    }

    public Class getMainClass() {
        return mainClass;
    }

    public JoinBean setMainClass(Class mainClass) {
        this.mainClass = mainClass;
        return this;
    }

    public String getMainTableName() {
        return mainTableName;
    }

    public JoinBean setMainTableName(String mainTableName) {
        this.mainTableName = mainTableName;
        return this;
    }

    public String getMainTableAlias() {
        return mainTableAlias;
    }

    public JoinBean setMainTableAlias(String mainTableAlias) {
        this.mainTableAlias = mainTableAlias;
        return this;
    }

    public String getMainField() {
        return mainField;
    }

    public JoinBean setMainField(String mainField) {
        this.mainField = mainField;
        return this;
    }

    public Class getJoinClass() {
        return joinClass;
    }

    public JoinBean setJonClass(Class joinClass) {
        this.joinClass = joinClass;
        return this;
    }

    public String getJoinTableName() {
        return joinTableName;
    }

    public JoinBean setJoinTableName(String jonTableName) {
        this.joinTableName = jonTableName;
        return this;
    }

    public String getJoinTableAlias() {
        return joinTableAlias;
    }

    public JoinBean setJoinTableAlias(String jonTableAlias) {
        this.joinTableAlias = jonTableAlias;
        return this;
    }

    public String getJoinField() {
        return joinField;
    }

    public JoinBean setJoinField(String joinField) {
        this.joinField = joinField;
        return this;
    }

    public JoinType getJoinType() {
        return joinType;
    }

    public JoinBean setJoinType(JoinType joinType) {
        this.joinType = joinType;
        return this;
    }
}
